package com.ehome.poct.core.api.virtual;

import com.ehome.poct.base.api.enums.StripTypeEnums;
import com.ehome.poct.core.api.constant.enums.ScanTypeEnums;
import com.ehome.poct.core.api.dto.check.TestRecordDetailDTO;
import com.ehome.poct.core.api.dto.order.PrePlaceOrderDTO;
import com.ehome.poct.core.api.dto.order.TestOrderDTO;
import com.ehome.poct.core.api.dto.order.TestOrderItemDTO;
import com.ehome.poct.core.api.dto.report.ProfitDTO;
import com.ehome.poct.core.api.vo.order.UnificationPayVO;
import com.ehome.poct.core.api.vo.order.UnificationShareAccountVO;
import com.google.common.collect.ImmutableList;
import org.assertj.core.util.Lists;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @auther: kuiba.peng
 * @date: 2022/11/23 09:39
 * @description:
 */
public interface TestOrderInternalPayService {

    List<Integer> BLOOD_STRIP_CODE_LIST = Lists.newArrayList(StripTypeEnums.BLD.getStripTypeCode());


    // 特殊联测、血常规报告
    List<StripTypeEnums> SPECIAL_REPORT_LIST = List.of(StripTypeEnums.SAA_CRP, StripTypeEnums.U_CRP_SAA_BLD_REPORT, StripTypeEnums.BLD);
    List<Integer> SPECIAL_REPORT_STRIP_CODE_LIST = ImmutableList.copyOf(SPECIAL_REPORT_LIST.stream().map(StripTypeEnums::getStripTypeCode).collect(Collectors.toList()));

    // 组合产品
    List<StripTypeEnums> BUNDLING_REPORT_LIST = List.of(StripTypeEnums.U_MPIGM_CPNIGM_REPORT, StripTypeEnums.U_MP_AB_CPNIGM_REPORT);
    List<Integer> BUNDLING_STRIP_CODE_LIST = ImmutableList.copyOf(BUNDLING_REPORT_LIST.stream().map(StripTypeEnums::getStripTypeCode).collect(Collectors.toList()));

    /**
     * 获取价格方案
     *
     * @param clinicId
     * @param stripeCodeList
     * @return
     */
    List<ProfitDTO> getPriceProfit(Long clinicId, List<Integer> stripeCodeList);

    /**
     * 根据检测代码转换为子商品
     *
     * @param clinicId
     * @param stripeCodeList
     * @param orderNo
     * @return
     */
    List<TestOrderItemDTO> convertOrderItems(Long clinicId, List<Integer> stripeCodeList, String orderNo);

    /**
     * 保存分账信息
     *
     * @param orderItemDTOList
     * @param profitDTOList
     * @param clinicId
     * @return
     */
    UnificationShareAccountVO saveShareAccount(List<TestOrderItemDTO> orderItemDTOList, List<ProfitDTO> profitDTOList, Long clinicId);

    /**
     * 唤起支付
     * 内部调用
     *
     * @param orderDTO
     * @param scanType
     * @param authCode
     * @return
     */
    UnificationPayVO internalPay(TestOrderDTO orderDTO, ScanTypeEnums scanType, String authCode);

    List<TestRecordDetailDTO> convertRecordDetailList(PrePlaceOrderDTO placeOrder, List<TestOrderItemDTO> orderItems);
}
